package cn.ffcs.unm.record.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.stereotype.Repository;

import cn.ffcs.unm.record.dao.RecordDao;
import cn.ffcs.unm.record.model.DelRecord;
import cn.ffcs.uom.common.dao.BaseDaoImpl;
import cn.ffcs.uom.common.util.StrUtil;
import cn.ffcs.uom.common.vo.PageInfo;

@Repository("recordDao")
public class RecordDaoImpl extends BaseDaoImpl implements RecordDao {

	@Override
	public PageInfo queryPageInfoByDelRecord(DelRecord delRecord, int currentPage, int pageSize) {
		StringBuilder sb = new StringBuilder();
		sb.append(" select distinct  ");
		sb.append(" ja1.MONTH_ID  monthID,ja1.UNIT_ID  unitId,ja1.TABLE_CODE tableCode,ja1.TABLE_PK  tablePk,");
		sb.append(" ja1.DELETE_TS  时间戳,decode(ja1.DEL_FLAG ,'Y','是','N','否')  delFlag,ja1.PK_TABLE_DELETE  pkTableDelete");
		sb.append("  from LDAPM_MPW_TEL_DATADEL_RECORD ja1 where 1=1 ");
		List<Object> params = new ArrayList<Object>();
		if (null != delRecord) {
			if (!StrUtil.isEmpty(delRecord.getMonthId())) {
				sb.append(" AND ja1.MONTH_ID = ? ");
				params.add(delRecord.getMonthId());
			}
			if (!StrUtil.isEmpty(delRecord.getTableCode())) {
				sb.append(" AND ja1.TABLE_CODE LIKE ? ");
				params.add("%" + StringEscapeUtils.escapeSql(delRecord.getTableCode()) + "%");
			}
		}
		return this.jdbcFindPageInfo(sb.toString(), params, currentPage,
				pageSize, DelRecord.class);
	}

}
